package ar.edu.caece.compiler.grammars.sample2.tokens;

import java.util.HashMap;

import ar.edu.caece.compiler.model.Token;
import ar.edu.caece.compiler.model.Token.Type;

public class TokenFactory {
	private static HashMap<Type, Class> instantiationMap;
	
	public TokenFactory() {
		instantiationMap = new HashMap<ar.edu.caece.compiler.model.Token.Type,java.lang.Class>();
		
		instantiationMap.put(Token.Type.ENTERO, NumToken.class);
		instantiationMap.put(Token.Type.SUMAENTERO, PlusToken.class);
		instantiationMap.put(Token.Type.IDENTIFIER, IdToken.class);
	}
	
	public static SampleToken getToken(Token.Type type) throws InstantiationException, IllegalAccessException {
		return (SampleToken) instantiationMap.get(type).newInstance();
	}
}
